{extend name='base'} 
{block name='content'}
<div class="box1">
	<form class="form-horizontal" method="post" enctype="multipart/form-data" id="field_form">
	{switch name=":request()->action()" }
	    {case value="add"} 
			<input type="hidden" name="table_name" value="{$Request.param.table_name}">
	    {/case}
	    {case value="edit"}
			<input type="hidden" name="oldname" value="{$r.name}">
			<input type="hidden" name="table_name" value="{$r.table_name}">
	    {/case} 
	{/switch} 
	<div class="form-group">
	    <label class="col-xs-2">字段名</label>
	    <div class="col-xs-10">
	    	<input type="text" class="form-control"  name="name" id="name" placeholder="字段名" value="{$r.name}">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-xs-2">字段标识</label>
	    <div class="col-xs-10">
	    	<input type="text" class="form-control"  name="title" id="title" placeholder="字段标识" value="{$r.title}">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-xs-2">输入过滤</label>
	    <div class="col-xs-10">
	    	<input type="text" class="form-control"  name="valid" id="valid" placeholder="输入过滤" value="{$r.valid}">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-xs-2">字段类型</label>
	    <div class="col-xs-10">
	    	 <select name="type" class="form-control pull-left">
	          <option value="VARCHAR">字符型0-255字节(VARCHAR)</option>
			  <option value="CHAR">定长字符型0-255字节(CHAR)</option>
	          <option value="TEXT">小型字符型(TEXT)</option>
	          <option value="MEDIUMTEXT">中型字符型(MEDIUMTEXT)</option>
	          <option value="LONGTEXT">大型字符型(LONGTEXT)</option>
	          <option value="TINYINT">小数值型(TINYINT)</option>
	          <option value="SMALLINT">中数值型(SMALLINT)</option>
	          <option value="INT">大数值型(INT)</option>
	          <option value="BIGINT">超大数值型(BIGINT)</option>
	          <option value="FLOAT">数值浮点型(FLOAT)</option>
	          <option value="DOUBLE">数值双精度型(DOUBLE)</option>
	          <option value="DATE">日期型(DATE)</option>
	          <option value="DATETIME">日期时间型(DATETIME)</option>
	        </select>
	        <div class="pull-left"> 
	       		长度<input type="number" name="length" class="form-control" style="width: 100px;display: inline-block;">
	        </div> 
	    </div> 
	</div>
	<div class="form-group">
	    <label class="col-xs-2">表单显示元素</label>
	    <div class="col-xs-10">
	    	<select id="f_form" name="f_form" class="form-control">
	          <option value="text">单行文本框(text)</option>
	          <option value="password">密码框(password)</option>
	          <option value="select">下拉框(select)</option>
	          <option value="radio">单选框(radio)</option>
	          <option value="checkbox">复选框(checkbox)</option>
	          <option value="textarea">多行文本框(textarea)</option>
	          <option value="editor">编辑器(editor)</option>
	          <option value="img">图片(img)</option> 
	          <option value="moreimg">图片集(moreimg)</option> 
	          <option value="file">文件(file)</option>
	          <option value="date">日期(date)</option> 
	        </select> 
	    </div>
	</div>
	<div class="form-group">
		<label class="col-xs-2">初始值</label>
		<div class="col-xs-10">
			<textarea name="s_value" id="s_value" class="form-control" style="height: 100px;"></textarea>
		</div>
	</div>
	<div class="form-group">
	    <label class="col-xs-2">输入表单</label>
	    <div class="col-xs-10">
	    	<textarea name="h_html" id="h_html" class="form-control" style="height: 200px;">{$r.h_html}</textarea>	 
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-xs-2">投稿表单</label>
	    <div class="col-xs-10">
	    	 <textarea name="q_html" id="q_html" class="form-control" style="height: 200px;">{$r.q_html}</textarea>
	    </div>
	</div> 

		<div class="form-group"> 
		    <div class="col-md-10 col-md-offset-2 col-xs-12">
		    	<input type="submit" class="btn btn-primary" value="确认提交">
		    </div>
		</div>
	</form>
</div>
<script type="text/javascript">
 	function getform() {
 		$.post("{:url('field/getForm')}", {name:$('#name').val(),title:$('#title').val(),f_form:$('#f_form').val(),s_value:$('#s_value').val(),valid:$('#valid').val()}, function(data, textStatus, xhr) {
			$('#q_html,#h_html').val(data);
		});
 	}
	$('#f_form').change(function () {
		getform();
	});
	$('#title').blur(function() {
		getform();
	});
	$('#s_value').blur(function() {
		getform();
	});
	$('#valid').blur(function() {
		getform();
	});
	$('#field_form').submit(function () {
		getform();
	})
</script>
{/block}